#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
#define rep(i, a, b) for (int i = (a); i <= (b); i++)
#define per(i, a, b) for (int i = (a); i >= (b); i--)
#define endl '\n'
const int N = 105;

int n, m;
char g[N][N];
int vis[N][N];
int ans = 0;
void dfs(int x, int y) {
  vis[x][y] = 1;
  rep(dx, -1, 1) rep(dy, -1, 1) {
    int nx = x + dx, ny = y + dy;
    if (nx < 1 || nx > n || ny < 1 || ny > m) continue;
    if (vis[nx][ny]) continue;
    if (g[nx][ny] != '@') continue;
    dfs(nx, ny);
  }
}
void solve() {
  rep(i, 1, n) rep(j, 1, m) cin >> g[i][j];
  rep(i, 1, n) rep(j, 1, m) vis[i][j] = 0;
  ans = 0;
  rep(i, 1, n) rep(j, 1, m) if (!vis[i][j] && g[i][j] == '@') dfs(i, j), ans++;
  cout << ans << endl;
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  while (cin >> n >> m && n && m) {
    solve();
  }
  return 0;
}